package cz.muni.fi.pa165.travelagency.dto;

import cz.muni.fi.pa165.travelagency.api.entities.IOrder;
import cz.muni.fi.pa165.travelagency.api.entities.IPackageTour;
import cz.muni.fi.pa165.travelagency.api.entities.ITour;
import cz.muni.fi.pa165.travelagency.entities.PackageTour;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlAdapter;

/**
 * Data transfer object for {@link PackageTour} entity.
 *
 * @author Lukas Jungmann
 * @version 1.0
 * @see PackageTour
 */
@XmlRootElement
public class PackageTourDTO implements IPackageTour {

    private static final long serialVersionUID = 7L;
    private Long id;
    private List<ITour> availableTours;
    private List<IOrder> orders = new ArrayList<>();
    private String name;
    private int capacity;
    private String description;
    private String destination;
    private Date start;
    private Date end;
    private BigDecimal pricePerPerson;

    public PackageTourDTO() {
        this.availableTours = new ArrayList<>();
    }

    @Override
    public Long getId() {
        return id;
    }

    @Override
    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public List<ITour> getAvailableTours() {
        return availableTours;
    }

    @Override
    public void setAvailableTours(List<ITour> availableTours) {
        this.availableTours = availableTours;
    }

    @Override
    public List<IOrder> getOrders() {
        return orders;
    }

    @Override
    public void setOrders(List<IOrder> orders) {
        this.orders = orders;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public int getCapacity() {
        return capacity;
    }

    @Override
    public void setCapacity(int capacity) {
        this.capacity = capacity;
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public String getDestination() {
        return destination;
    }

    @Override
    public void setDestination(String destination) {
        this.destination = destination;
    }

    @Override
    public Date getStart() {
        return start;
    }

    @Override
    public void setStart(Date start) {
        this.start = start;
    }

    @Override
    public Date getEnd() {
        return end;
    }

    @Override
    public void setEnd(Date end) {
        this.end = end;
    }

    @Override
    public BigDecimal getPricePerPerson() {
        return pricePerPerson;
    }

    @Override
    public void setPricePerPerson(BigDecimal pricePerPerson) {
        this.pricePerPerson = pricePerPerson;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 37 * hash + Objects.hashCode(this.id);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final PackageTourDTO other = (PackageTourDTO) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "PackageTour{" + "id=" + id + ", name=" + name + ", capacity=" + capacity + ", description=" + description + ", destination=" + destination + ", start=" + start + ", end=" + end + ", pricePerPerson=" + pricePerPerson + '}';
    }
    
    static class Adapter extends XmlAdapter<PackageTourDTO,IPackageTour> {

        @Override
        public IPackageTour unmarshal(PackageTourDTO v) throws Exception {
            return v;
        }

        @Override
        public PackageTourDTO marshal(IPackageTour v) throws Exception {
            return (PackageTourDTO) v;
        }
        
    }
}
